<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Person Table</title>
</head>
<body>

<h1>Persons</h1>
<table style="border-collapse: collapse" border="1">
    <c:if test="${success==true }">
        <span style="color:green">Success!</span>
    </c:if>
    <c:if test="${success==false}">
        <span style="color:red">ERROR!</span>
    </c:if>

    <tr>
        <td>Name</td>
        <td>Age</td>
    </tr>
    <%
        int i = 0;
    %>
    <c:forEach items="${persons}" var="person">
        <tr>
            <td>${person.name}</td>
            <td>${person.age}</td>
            <td><button onclick="window.location.href='deletePerson/<%=i%>'">Delete</button> </td>
        </tr>
        <%i++;%>
    </c:forEach>
</table>
<a href="addPerson">Add person</a>


</body>
</html>
